﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Text.RegularExpressions;

namespace DocManagerORM.ValRules
{
    public class ValidaEmail : ValidationRule
    {

        public override ValidationResult  Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {                   
            var validateMail  =
                @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-z]{2,4}|[0-9]{1,3})(\]?)$";
 
            var result = Regex.IsMatch(value.ToString(), validateMail);
 
            if(result ) 
                return new ValidationResult(true, null);
            else 
                return new ValidationResult(false, "Non è un indirizzo email valido");        

        }

    }//fC
}
